//
//  UIView+LXLFrame.m
//  lxl
//
//  Created by lxl on 15/10/11.
//  Copyright (c) 2015年 lxl. All rights reserved.
//

#import "UIView+LXLFrame.h"

@implementation UIView (LXLFrame)

#pragma mark 存取宽度
-(void)setWidth:(CGFloat)width
{
    CGRect newFrame = self.frame;
    newFrame.size.width = width;
    self.frame = newFrame;
}

-(CGFloat)width
{
    return self.frame.size.width;
}
#pragma mark 存取高度
-(void)setHeight:(CGFloat)height
{
    CGRect newFrame = self.frame;
    newFrame.size.height = height;
    self.frame = newFrame;
}
-(CGFloat)height
{
    return self.frame.size.height;
}
#pragma mark 存取上Y
-(void)setMinY:(CGFloat)minY
{
    CGRect newFrame = self.frame;
    newFrame.origin.y = minY;
    self.frame = newFrame;
}
-(CGFloat)minY
{
    return self.frame.origin.y;
}
#pragma mark 存取下Y
-(void)setMaxY:(CGFloat)maxY
{
    CGRect newFrame = self.frame;
    newFrame.origin.y = maxY - self.frame.size.height;
    self.frame = newFrame;

}
-(CGFloat)maxY
{
    return CGRectGetHeight(self.frame) + CGRectGetMinY(self.frame);
}
#pragma mark 存取左X
-(void)setMinX:(CGFloat)minX
{
    CGRect newFrame = self.frame;
    newFrame.origin.x = minX;
    self.frame = newFrame;
}
-(CGFloat)minX
{
    return CGRectGetMinX(self.frame);
}
#pragma mark 存取右X
-(void)setMaxX:(CGFloat)maxX
{
    CGRect newFrame = self.frame;
    newFrame.origin.x = maxX - CGRectGetWidth(self.frame);
    self.frame = newFrame;
}
-(CGFloat)maxX
{
    return CGRectGetMaxX(self.frame);
}

@end
